from django.db import models
from django.contrib.auth.models import AbstractUser
# Create your models here.


class User(AbstractUser):
    mobile = models.CharField('手机号',max_length=11)

    def __str__(self):
        return self.username

    class Meta:
        db_table = 'user'
        verbose_name_plural = '用户表'


# 用户地址模型类
#     id       receiver     receive_mobile     receive_addr    is_default   user_id
#            varchar(30)    varchar(11)       varchar(100)     boolean      1
class UserAddr(models.Model):
    receiver = models.CharField('收件人',max_length=30)
    receive_mobile = models.CharField('收货人手机号',max_length=11)
    receive_addr = models.CharField('收件人地址',max_length=100)
    is_default = models.BooleanField('是否默认',default=False)
    user_id = models.ForeignKey(User,on_delete=models.CASCADE,verbose_name='属于哪个用户')

    def __str__(self):
        return self.receiver

    class Meta:
        db_table = 'user_addr'
        verbose_name_plural = '收货地址'






